export default {
	data() {
		return {
			// 判断是否有中标记录
			bidList:null,
			// 存贮中标记录信息
			bigRecord:[],
			bidName:null,
			winningbidName:null,
			// 记录当前页数
			page:1,
			// 记录总页数
			allPage:null,
			status: 'loadmore',
			// 记录当前的公司cid
			companyCid:null
			
		}
	},
	onLoad(option) {
		
		// 查询该公司详情
		this.companyCid=option.companyCid
		this.checkBidList(option.companyCid)

	},
	onReachBottom() {
	
				if(this.page >= this.allPage) {
					this.status = 'nomore';
					return 
				}
				this.status = 'loading';
				this.page = ++ this.page;
				setTimeout(() => {
					this.checkBidList(this.companyCid)
					if(this.page >= 3) this.status = 'nomore';
					else this.status = 'loading';
				}, 2000)
			},
	methods: {
		toNoticeDetile(item){
			// 跳转至详情页
			if(item.toDetail){
				uni.navigateTo({
					url: '/pagesIndex/detail?id=' + item._id
				});
			}
		},
		// 跳转至详情页面
		toRecordPage(item){
			//将对象中网页的参数，传递至下一页面
			
			uni.navigateTo({
				url:`/pagesFind/detailenterprise/recordPage/recordPage?companyBidOriUrl=${item.companyBidOriUrl}`
			})
		},
		// 查询该公司中标数量
		checkBidList(id) {
			this.$app.request({
				url: this.$baseApp.api.dicData.companyBiddingList,
				data: {
					'companyCid': id,
					'page':this.page
				},
				method: 'GET',
				dataType: 'json',
				success: res => {
					if (res.code == 200) {
						
						this.allPage=res.data.totalPages
						
						if (this.allPage <= 1||res.data.content.length<10) {
							this.status = 'nomore'
						}
						
						
						res.data.content.forEach((item)=>{
							if(item._id.indexOf('_')>-1){
								item.toDetail=true
							}
							
							if(item.companyBidPurchaserList){
								if(item.companyBidPurchaserList[0])
								item.winBigNmae=item.companyBidPurchaserList[0].name
							}
							if(item.companyBidSupplierList){
								if(item.companyBidSupplierList[0])
								item.bigName=item.companyBidSupplierList[0].name
							}
							this.bigRecord.push(item)
						})
						this.bidList = this.bigRecord.length
						// console.log("this.bidList", this.bidList,this.bigRecord)
					} else {

						this.showTip(res.msg)
					}
				},
				complete: res => {
					uni.stopPullDownRefresh();
					uni.hideLoading();
				}
			});
		},
	}
}
